<?php include_once 'header.php'; ?>
    <script type="text/javascript" src="/public/statics/libs/wangEditor/dist/js/lib/jquery-1.10.2.min.js"></script>
    <div id="page-wrapper">
        <div class="container-fluid">
            <div class="row" style="margin-top:20px;">
                <a href="/administrator/announceAdd" class="btn btn-default">添加公告</a>
            </div>
            <div class="row" style="margin-top: 20px;">
                <div class="table-responsive">
                    <table class="table table-striped table-hover">
                        <thead>
                        <tr>
                            <th>#</th>
                            <th>标题</th>
                            <th>发布时间</th>
                            <th>更新时间</th>
                            <th width="600">操作</th>
                        </tr>
                        </thead>
                        <tbody>
                        <?php foreach ($datas as $item) { ?>
                            <tr>
                                <td><?php echo $item->id; ?></td>
                                <td><?php echo $item->body_title; ?></td>
                                <td><?php echo $item->created_at; ?></td>
                                <td><?php echo $item->updated_at; ?></td>
                                <td>
                                    <a href="javascript:;" onclick="del(<?php echo $item->id; ?>);">删除</a> | <a href="/administrator/announceEdit/<?php echo $item->id; ?>">编辑</a>
                                </td>
                            </tr>
                        <?php } ?>
                        </tbody>
                        <tfoot>
                        <tr>
                            <td colspan="10" style="text-align: center;">
                                <ul class="pagination">
                                    <li class="paginate_button previous"><a href="<?php echo $datas->previousPageUrl(); ?>">上一页</a></li>
                                    <li class="paginate_button active"><a href="#"><?php echo $datas->currentPage(); ?> / <?php echo $datas->lastPage(); ?>, 共 <?php echo $datas->total(); ?> 条记录</a></li>
                                    <li class="paginate_button next"><a href="<?php echo $datas->nextPageUrl(); ?>">下一页</a></li>
                                </ul>
                            </td>
                        </tr>
                        </tfoot>
                    </table>
                </div>
            </div>
        </div>
    </div>
<script type="text/javascript">
    function del(id){
        $.get('/administrator/announceDel/'+id,function(data){
            alert(data.message);
            if(data.state == 'ok'){
                window.location.reload();
            }
        },'JSON');
    }
</script>
<?php include_once 'footer.php'; ?>